package com.wenli.lt.util;

import java.util.HashMap;
import java.util.Map;

/**
 * @author xy
 * 2019/5/19
 */
public class LoginCommonResponse<T> {

    public final static String SUCCESS_INFO = "ok";
    public final static int ERROR_CODE = 500;
    public final static int PERMISSION_DENIED_CODE = 403;

    private int errorCode;
    private String errorMessage;
    private T data;
    private Map meta;

    public LoginCommonResponse() {
    }

    public LoginCommonResponse(T data,Integer status) {
        this.errorCode = 0;
        this.errorMessage = null;
        this.data = data;
        Map map = new HashMap();
        if (status == 0){

            map.put("msg","登录成功");
            map.put("status","200");
        }else if (status == 1){
            map.put("msg","登录失败,请输入正确的账号密码!");
            map.put("status","500");
        }else if (status == 2){
            map.put("msg","更改成功");
            map.put("status","200");
        }else if (status == 3){
            map.put("msg","更改失败,请输入正确的账号密码!");
            map.put("status","500");
        }
        this.meta =map;


    }

    public LoginCommonResponse(int errorCode, String errorMessage) {
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
        this.data = null;
    }

    public LoginCommonResponse(int errorCode, String errorMessage, T data) {
        this.data = data;
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    public int getErrorCode() {
        return this.errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMessage() {
        return this.errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public T getData() {
        return this.data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Map getMeta() {
        return this.meta;
    }

    public void setMeta(Map meta) {
        this.meta = meta;
    }

    public String toString() {
        return "CommonResponse{errorCode=" + this.errorCode + ", errorMessage='" + this.errorMessage + '\'' + ", data=" + this.data + '\'' + ", meta=" + this.meta + '}';
    }
}
